package com.lbs.jiepiaisi.biz;

import android.content.Intent;
import android.util.Log;

import com.lbs.jiepiaisi.bean.CityEntity;
import com.lbs.jiepiaisi.manager.App;
import com.lbs.jiepiaisi.parser.cityParser;
import com.lbs.jiepiaisi.utils.Constant;
import com.lbs.jiepiaisi.utils.HttpUtil;
import com.lbs.jiepiaisi.utils.UrlUtil;

import okhttp3.FormBody;
import okhttp3.Response;

/**
 *
 * 时间：2017/11/6 16:16
 * 作用：
 */

public class ChengShiLieBiaoBiz {

    public void chengShiLieBiaoBiz(){
        FormBody formBody=new FormBody
                .Builder()
                .build();
        HttpUtil.getHttpUtil().post(UrlUtil.CHENG_SHI_LIE_BIAO,formBody, new HttpUtil.Listener() {
            @Override
            public void success(Response response) {

                CityEntity cityEntity=new CityEntity();

                try{
                    //返回结果
                    String jsonString = response.body().string();
                    Log.e("TAG","城市列表信息："+jsonString);
                    cityEntity= cityParser.parser(jsonString);
                }catch (Exception e){
                    cityEntity.setStatus("1");
                    e.printStackTrace();
                }finally {
                    Intent intent = new Intent(Constant.CHENG_SHI_XIN_XI);
                    intent.putExtra(Constant.KEY_DATA, cityEntity);
                    App.instance.sendBroadcast(intent);
                }
            }

            @Override
            public void failed() {
                //失败

            }

            @Override
            public void noNetwork() {
                //网络连接失败


            }
        });

    }
}
